/**
 * 句中单词首字母大写
 * @param str
 * @returns {string}
 * String.toLowerCase().split()
 * charAt(0).toUpperCase()+xxx.slice(1);
 *
 */
function titleCase(str) {
    // string -> []
    let words = str.toLowerCase().split(" ");
    // toUppercase.slice
    for(let i =0;i<words.length;i++){
        words[i] = words[i].charAt(0).toUpperCase()+words[i].slice(1);
        //console.log(words[i]);
    }

    return words.join(" ");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));